﻿@{
    ViewData["Title"] = "用户管理";
}
@model AdoUser

<div id="app">
    <form class="layui-form form-cus" action="" lay-filter="forms">

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">账号</label>
                <div class="layui-input-inline">
                    <input type="text" name="LoginAccount" value="@Model.LoginAccount"
                           placeholder="请输入账号" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-inline">
                    <input type="text" name="Pwd" value="@Model.Pwd"
                           placeholder="请输入密码" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-inline">
                    <input type="text" name="NickName" value="@Model.NickName"
                           placeholder="请输入昵称" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">手机</label>
                <div class="layui-input-inline">
                    <input type="tel" name="Phone" value="@Model.Phone"
                           lay-verify="required" lay-verType="tips" autocomplete="off" placeholder="请输入手机" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">QQ</label>
                <div class="layui-input-inline">
                    <input type="text" name="QQ" value="@Model.QQ"
                           lay-verify="required" lay-verType="tips" autocomplete="off" placeholder="请输入QQ" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">微信</label>
                <div class="layui-input-inline">
                    <input type="text" name="WX" value="@Model.WX"
                           lay-verify="required" lay-verType="tips" autocomplete="off" placeholder="请输入微信" class="layui-input">
                </div>
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="Sex" lay-skin="switch" lay-text="男|女" value="true" @(Model.Sex ? "checked" : "")>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                    <input type="text" name="Email" value="@Model.Email"
                           lay-verify="required" lay-verType="tips" autocomplete="off" placeholder="请输入邮箱" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">是否启用</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="IsEnable" lay-skin="switch" lay-text="开启|禁用" value="true" @(Model.IsEnable ? "checked" : "")>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">头像</label>
            <div class="layui-input-block">
                <div class="layui-upload">
                    <button type="button" class="layui-btn layui-btn-warm dl-cloud" data-text="HeadPic" data-type="iframe">上传头像</button>
                    <div class="layui-upload-list">
                        <img class="layui-upload-img" style="width:180px; height:220px;" id="HeadPic_Img" name="HeadPic_Img" src="@Model.HeadPic">
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <input type="text" name="Remark" value="@Model.Remark"
                       lay-verify="required" lay-verType="tips" autocomplete="off" placeholder="请输入备注" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-cur-submit">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="submit" id="submit">
                    <i class="layui-icon layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop layui-hide"></i>立即提交
                </button>
                <button type="button" class="layui-btn layui-btn-primary btn-open-close">取消</button>
            </div>
        </div>
        <input type="hidden" name="ID" id="ID" value="@Model.ID" />
        <input type="hidden" name="Creator" id="Creator" value="@Model.Creator" />
        <input type="hidden" name="CreateTime" id="CreateTime" value="@Model.CreateTime" />
        <input type="hidden" name="HeadPic" id="HeadPic" value="@Model.HeadPic" />
        <input type="hidden" name="LoginTime" value="@Model.LoginTime" />
        <input type="hidden" name="LoginIp" value="@Model.LoginIp" />
        <input type="hidden" name="LoginCount" value="@Model.LoginCount" />
        <input type="hidden" name="LastLoginTime" value="@Model.LastLoginTime" />
    </form>
</div>
@section Scripts{
    <script type="text/javascript">
        layui.config({
            base: '/js/modules/'
        }).use(['layer', 'laydate', 'jquery', 'api', 'form'], function () {
            var form = layui.form,
                $ = layui.$,
                laydate = layui.laydate,
                api = layui.api,
                index = parent.layer.getFrameIndex(window.name);

            api.cloudFile();

            laydate.render({
                elem: '#UpLoginDate',
                theme: '#393D49'
            });
            laydate.render({
                elem: '#LoginDate',
                theme: '#393D49'
            });

            //监听提交
            form.on('submit(submit)', function (data) {

                $('#submit').attr('disabled', true).find('i').removeClass('layui-hide');
                var url = "Ado/User/Add";
                if ($("#ID").val()) {
                    url = "Ado/User/Update";
                }

                api.ajax(url, 'POST', data.field, function (res) {
                    $('#submit').attr('disabled', false).find('i').addClass('layui-hide');
                    if (res.statusCode === 200) {
                        api.success(res.msg);
                        parent.layer.close(index);
                    } else {
                        api.error(res.msg);
                    }
                });
                return false;
            });
            $(".btn-open-close").on('click', function () {
                parent.layer.close(index);
            });
        });
    </script>
}